/**
 * Copyright 2016-2018 mobaas.com
 */
package com.mobaas.devops.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.mobaas.devops.PageList;
import com.mobaas.devops.model.WebUrl;
import com.mobaas.devops.model.WebUrlLog;
import com.mobaas.devops.service.ContainerService;
import com.mobaas.devops.service.WebUrlService;

/**
 * 
 * @author billy zhang
 * 
 */
@Controller
@RequestMapping("/ops")
public class OpsController {

	@Autowired
	private WebUrlService weburlService;
	
	@RequestMapping("hostlist")
	public ModelAndView hostList() {
		
		List<WebUrl> list = weburlService.selectWebUrlList(0);
		
		ModelAndView mv = new ModelAndView();
		mv.addObject("list", list);
		mv.setViewName("/ops/containerlist");
				
		return mv;
	}
	
	@RequestMapping("applist")
	public ModelAndView appList() {
		
		List<WebUrl> list = weburlService.selectWebUrlList(0);
		
		ModelAndView mv = new ModelAndView();
		mv.addObject("list", list);
		mv.setViewName("/ops/applist");
				
		return mv;
	}
	
	@RequestMapping("containerlist")
	public ModelAndView containerList() {
		
		List<WebUrl> list = weburlService.selectWebUrlList(0);
		
		ModelAndView mv = new ModelAndView();
		mv.addObject("list", list);
		mv.setViewName("/ops/containerlist");
				
		return mv;
	}
	
	@RequestMapping("weburllist")
	public ModelAndView urlList() {
		
		List<WebUrl> list = weburlService.selectWebUrlList(0);
		
		ModelAndView mv = new ModelAndView();
		mv.addObject("list", list);
		mv.setViewName("/ops/weburllist");
				
		return mv;
	}
	
	 @RequestMapping(value = "weburlloglist", method = RequestMethod.GET)
    public ModelAndView urllogList(
            @RequestParam(value = "pageNum", defaultValue = "1", required = false) int pageNum,
            @RequestParam(value = "pageSize", defaultValue = "15", required = false) int pageSize) {
        ModelAndView model = new ModelAndView();

        PageList<WebUrlLog> page = weburlService.selectWebUrlLogList(0, pageNum, pageSize);
        model.addObject("page", page);

        model.setViewName("/ops/weburlloglist");

        return model;
    }
	
}
